from pyglet_render.viewer import Viewer
from ship_envs.core.model_transformer import model2geom
from ship_envs.core.rect_model import RectModel
import numpy as np

if __name__ == '__main__':
    viewer = Viewer(700, 700)
    viewer.set_bounds(0,1,0,1)
    rect = RectModel(0.5, 0.5)
    rect.color = np.array([0.25, 0.25, 0.25])
    rect.rotate(15)
    rect.rotate(15)
    rect.rotate(30)
    viewer.add_onetime(model2geom(rect))
    viewer.render()
    rect.set_angle(0)
    viewer.add_onetime(model2geom(rect))
    viewer.render()
    print(1)
    for _ in range(10):
        rect.set_angle(0)
        rect.set_pos((0.5,0.5))
        viewer.add_onetime(model2geom(rect))
        viewer.render()
        for _ in range(100):
            rect.move(0.005)
            rect.rotate(np.random.choice([15, 5, -10]))
            viewer.add_onetime(model2geom(rect))
            viewer.render()